<?
function readFileContent($filePath){
	//$fp = fopen($filePath,"r");
	//$buf = fread($fp,filesize($filePath));
	//fclose($fp);
	$buf2 = file_get_contents($filePath);
	return $buf2;
}

function createFile($filename,$content){ 
    file_put_contents($filename,$content);
    chmod($filename,0644);
//	chmod($filename,0777);
}  

 function fixsql($txt,$int_type){
    $var = $_GET[$txt];
	if($var==''){
		$var = $_POST[$txt];
	}
	$var = trim($var);
 	if($int_type==0){
		if($var==''){
			return 0;
		}else{
			return (int) $var;
		}
	}
	return $var;
 }

 function del($path,$file_name){
    if($file_name!="" && $file_name!="no.gif"){
		$file_path = realpath($path . "/" . $file_name);
		if(file_exists($file_path)){
			unlink($file_path);
		} 
	}
 }
 
 function addZero($txt,$num){
    if($txt != ""){
		if($num==3){
			if($txt<10){
				return "00" . $txt;
			}else if($txt < 100){
				return "0" . $txt;
			}else{
				return $txt;
			}
			
		}else if($num == 2){
			if($txt<10){
				return "0" . $txt;
			}else{
				return $txt;
			}
		}
	}	
 }
 
 function GetParentToHidden(){    
    $tmp_par = "";
	foreach($_GET as $key=>$target){ 
	     if($key != "account" && $key != "password" && $key != "do_login" && $key != "u" && $key != "page" && $key != "int_Var"){  
			$tmp_par.="<input type=\"hidden\" name=\"$key\" value=\"$target\">\n";
		 }
	}
	foreach($_POST as $key=>$target){   
		if($key != "account" && $key != "password" && $key != "do_login" && $key != "u" && $key != "page" && $key != "int_Var"){ 
			$tmp_par.="<input type=\"hidden\" name=\"$key\" value=\"$target\">\n";
		}	 
	}
	return $tmp_par;
 }	   
 
 function redirect($url){
   echo "<script>window.location='".$url."';</script>";
   exit;
 }
 
 function getUpDownSql($t_name){
	$tmp = ""; 
	if($t_name <> ""){ 
		$t_name .= ".";
	}
	$realDate = date('Y-m-d',time());
	$tmp  = $t_name . "upordown=1 and ((" . $t_name . "uptime<='" . $realDate . "' and " . $t_name . "downtime='') ";
    $tmp .= "or (" . $t_name . "uptime='' and " . $t_name . "downtime='') or (";
	$tmp .= $t_name . "uptime='' and " . $t_name . "downtime>'";
    $tmp .= $realDate  . "') or (" . $t_name . "uptime<='" . $realDate . "' and " . $t_name . "downtime>'" . $realDate . "'))";
	return $tmp;
 }
 
 function getRealDate(){
 	return date('Y-m-d',time());
 }

 function getRealTime(){
 	return date('Y-m-d H:i:s',time());// + 8*60*60); 
 } 
 
 function getRandNum(){
 	return time() . rand(1000,2000);
 }

function showStr($str,$len){
	if($len < (strlen($str)/2)){
		$tempStr = cutStr($str,0,$len);
		$tempStr .= "...";
	}else{
		$tempStr =$str;
	}
	return $tempStr;
}

?>